Contents | Index | < Browse | Browse >
LETTERfilebufULETTER
The file buffer for the fstream, ifstream and ofstream classes.
Overview
#include <fstream.h>
class filebuf : public streambuf {
public:
filebuf();
virtual ~filebuf();
int is_open();
filebuf *open(const char *, int);
filebuf *close();
virtual streampos seekoff(streamoff, ios::seek_dir, int = ios::in|ios::out);
virtual streampos seekpos(streampos, int = ios::in|ios::out);
virtual streambuf *setbuf(char *, size_t);
virtual int sync();
protected:
virtual int doallocate();
virtual int overflow(int = EOF);
virtual int underflow();
virtual int xsputn(const char *, int);
virtual int xsgetn(char *, int);
virtual int pbackfail(int);
};
Portability
AT&T Release 2 streams library
Description
This class provides the char buffer for in- and output on files. There is
only one pointer for both read- and write operations, so you can change from
between in- and output at any time.
Constructors
filebuf::filebuf();
Initializes the file buffer without opening a file.
Deconstructors
virtual ~filebuf();
Closes a file if it is open.
Methods
int filebuf::is_open();
Returns 1 if a file is opened and 0 otherwise.
filebuf *filebuf::open(const char *, int);
Opens a file using an ios::open_mode mask.
filebuf *filebuf::close();
Closes the file.
streampos filebuf::seekoff(streamoff, ios::seek_dir, int = ios::in|ios::out);
Sets the read/write pointer to a new position.
streampos filepos::seekpos(streampos, int = ios::in|ios::out);
Sets the read/write pointer to a new position.
streambuf *filebuf::setbuf(char *, size_t);
Attempts to set the file buffer to the specified buffer with the specified
size. Returns NULL, if the buffer could not be used.
int filebuf::sync();
Synchronizes the buffer and the file. If there are any characters for
output in the buffer these will be written. If there is unprocessed input
the file's read/write pointer will be corrected to this position. In any case
the buffer will be cleared.
See also
streambuf , fstream , ifstream , ofstream